package 反射.作业;

import cn.itcast.domain.Student;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class 通过反射操作普通方法 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Class clazz1 = new Student().getClass();

        Method eat = clazz1.getDeclaredMethod("eat");

        eat.setAccessible(true);

        Object invoke = eat.invoke(new Student());

        System.out.println(invoke);

        Class clazz2 = Student.class;

        Method he = clazz2.getDeclaredMethod("he");

        he.setAccessible(true);

        he.invoke(new Student());
    }
}
